<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_themeGraph"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="title" style="position:absolute;top: 10px;text-align:center;width:100%;z-index: 10;color: #f7931e" data-i18n="resources.text_GDPStatistic"></div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/maplibregl/include-maplibregl.js"></script>
<span id="show"></span>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";

    var attribution = "<a href='https://maplibre.org/' target='_blank'>© MapLibre </a>" +
       "with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
       " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";

    var dataUrl = host + "/iserver/services/map-china400/rest/maps/China";
    var map = new maplibregl.Map({
        container: 'map',
        style: {
            "version": 8,
            "sources": {
                "raster-tiles": {
                    "attribution": attribution,
                    "type": "raster",
                    "tiles": [host + '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?&z={z}&x={x}&y={y}'],
                    "tileSize": 256,
                },
            },
            "layers": [{
                "id": "simple-tiles",
                "type": "raster",
                "source": "raster-tiles",
                "minzoom": 0,
                "maxzoom": 22
            }]
        },
        center: [104, 38],
        zoom: 3.55
    });
    map.addControl(new maplibregl.NavigationControl(), 'top-left');
    map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');

    function createTheme() {
        themeGraph = new maplibregl.supermap.ThemeGraph({
            items: [
                new maplibregl.supermap.ThemeGraphItem({
                    caption: "全国省份2013_GDP",
                    graphExpression: "GDP_2013",
                    uniformStyle: new maplibregl.supermap.ServerStyle({
                        fillForeColor: new maplibregl.supermap.ServerColor(255, 215, 0),
                        lineWidth: 0
                    })
                }),
                new maplibregl.supermap.ThemeGraphItem({
                    caption: "全国省份2014_GDP",
                    graphExpression: "GDP_2014",
                    uniformStyle: new maplibregl.supermap.ServerStyle({
                        fillForeColor: new maplibregl.supermap.ServerColor(0, 191, 255),
                        lineWidth: 0
                    })
                }),
            ],
            barWidth: 0.001,
            graduatedMode: maplibregl.supermap.GraduatedMode.CONSTANT,
            graphAxes: new maplibregl.supermap.ThemeGraphAxes({
                axesDisplayed: true
            }),
            graphSize: new maplibregl.supermap.ThemeGraphSize({
                maxGraphSize: 500000,
                minGraphSize: 200000
            }),
            graphText: new maplibregl.supermap.ThemeGraphText({
                graphTextDisplayed: true,
                graphTextFormat: maplibregl.supermap.ThemeGraphTextFormat.VALUE,
                graphTextStyle: new maplibregl.supermap.ServerTextStyle({
                    fontHeight: 10,
                    fontWidth: 10
                })
            }),
            overlapAvoided: false,
            graphSizeFixed: false,
            graphType: maplibregl.supermap.ThemeGraphType.BAR
        });
        themeParameters = new maplibregl.supermap.ThemeParameters({
            themes: [themeGraph],
            datasetNames: ["China_Province_pg"],
            dataSourceNames: ["China"]

        });

        new maplibregl.supermap.ThemeService(dataUrl).getThemeInfo(themeParameters).then(function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                map.addSource("theme", {
                    "type": 'raster',
                    "tiles": [host + '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true&cacheEnabled=false&layersID=' + result.newResourceID],
                    "tileSize": 256,
                });

                map.addLayer({
                    "id": "themeLayer",
                    "type": "raster",
                    "source": "theme",
                });
            }
        })
    }

    map.on('load', function () {

        createTheme();
    });

</script>

</body>
</html>